<?php include (dirname(__FILE__)."/../include/header.php"); ?>
<?php if(!isset($_SESSION['_user'])){header("location:../user_login.php");}?>
<?php	
	$method =$_REQUEST['method'];
	if($method == "update"){
	$old_password=$_POST['old_password'];
	$new_password=$_POST['new_password'];
	$new_password1=$_POST['new_password1'];
	$sql="select * from zy_user where username ='".$_SESSION['_user']['username']."'";
	//echo $sql;
	$result=mysql_query($sql);
	$zy_user=mysql_fetch_array($result);
	//echo $zy_user['password'];
	if($old_password!=$zy_user['password']){
		$error="您输入的原密码有误!";
	}
	if($old_password==""){
		$error="原密码不能为空";
	}else if($new_password==""){
		$error="新密码不能为空";
	}else if($new_password1==""){
		$error="新密码不能为空";
	}
	if($new_password != $new_password1){
		$error="两次密码不一致";
	}
	if(strlen($new_password)<6){
		$error="新密码长度不能少于6位";
	}
	if($old_password == $zy_user['password'] && $new_password == $new_password1 && $new_password1 != null&&strlen($new_password)>=6){
	$sql= "update zy_user set password='".$new_password."' where user_id='".$_SESSION['_user']['user_id']."'";
	mysql_query($sql);
	$error="修改成功";
	//header("location:edit_password.php");
	}
}
?>
<div class="container">
	<ul class="breadcrumb">
     <li><a href="<?php echo SITE_ROOT; ?>">返回首页</a><span class="divider">/</span></li>
     <li><a href="<?php echo SITE_ROOT."/user/edit_password.php"; ?>">修改密码</a></li>
      </ul>

<div class="row">
    <div class="span12 wash-paper user-center profile">
        <div class="row">
            <div class="span3">
<?php include (dirname(__FILE__)."/../include/user/left.php"); ?>

            <div class="span9">
                <div class="main-content">
                    <div class="content-header">
                        <h3>修改密码</h3>
                    </div>
                    <div class="content-inner changepwd">
    <form class="form-horizontal" method="post" id="changepwd_form" action="<?php echo SITE_ROOT;?>/user/edit_password.php?method=update">
	<div class="field_line" ><font color="red"><?php echo $error;?></font></div>
      <fieldset>

      <div class="control-group clear-fix">
        <label class="control-label" for=""><span class="required">*</span>原密码</label>
        <div class="controls">
          <input name="old_password" id="sf_guard_user_old_pwd" type="password" />
          <p class="help-block">(请输入现在正在使用的密码)</p>
        </div><!--end input-->
      </div><!--end clearfix-->

      <div class="control-group">
        <label class="control-label" for=""><span class="required">*</span>新密码</label>
        <div class="controls">
          <input name="new_password" id="sf_guard_user_new_pwd" type="password"/ >
          <p class="help-block">（请输入新密码）</p>
        </div><!--end input-->
      </div><!--end clearfix-->

      <div class="control-group clear-fix">
        <label class="control-label" for=""><span class="required">*</span>重复新密码</label>
        <div class="controls">
          <input name="new_password1" id="sf_guard_user_repeat_pwd" type="password">
          <p class="help-block">(请再输入一次新密码)</p>
        </div><!--end input-->
      </div><!--end clearfix-->

      <div class="form-actions">
        <input type="submit" class="btn btn-yellow" id="sf_guard_user_changepwd_submit" name="submit" value="提交更改" />
      </div>
    </fieldset>
  </form>
                    </div><!--end contentarea-->
            </div>
         </div>
        </div>
    </div>
</div>
                      <a id="back-to-top" href="javascript:void(0);">
              <div class="backtotop"></div>
            </a>
                  </div>
<?php include (dirname(__FILE__)."/../include/footer.php"); ?>     